package com.qf.utils;

import java.math.BigInteger;
import java.security.MessageDigest;

/**

 * projectName:myxiaomi

 * author:liuXin

 * time:2022/6/24 17:21

 * description:
 */
public class MD5Utils {
	//加密
	public static String md5(String str){//123456   e10adc3949ba59abbe56e057f20f883e
		try {
			//1获取消息摘要
			MessageDigest md5 = MessageDigest.getInstance("MD5");
			byte[] bytes = str.getBytes("UTF-8");
			for (int i = 0; i < bytes.length; i++) {
				bytes[i]-=5;
			}
			//2更新
			md5.update(bytes);
			//3加密
			byte[] digest = md5.digest();
			//4返回
			return new BigInteger(1,digest).toString(16);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	public static void main(String[] args) {
		System.out.println(md5("123456"));
	}
}